import type {
  AxiosRequestConfig,
  InternalAxiosRequestConfig,
  AxiosResponse,
  AxiosInstance,
  AxiosError,
} from 'axios'

export interface AxiosOptions extends AxiosRequestConfig {
  directlyGetdata?: boolean
  interceptors?: RequestInterceptors
  abortRepetitiveRequest?: boolean
  retryConfig?: {
    count: number
    waitTime: number
  }
}

export abstract class RequestInterceptors {
  abstract requestInterceptors?: (config: InternalAxiosRequestConfig) => InternalAxiosRequestConfig
  abstract requestInterceptorsCatch: (err: Error) => Error
  abstract responseInterceptors?: (
    res: AxiosResponse<unknown, unknown>,
  ) => AxiosResponse<unknown, unknown> | Promise<unknown>
  abstract responseInterceptorsCatch?: (axiosInstance: AxiosInstance, error: AxiosError) => void
}

export interface ErrorRespones {
  code: number
  msg: string
}

export interface SuccessRespones<T = any> {
  code: number
  data: T[]
  msg: string
}
